﻿(function () {
    'use strict';
    var app = angular.module('app', [
        'ngRoute'
    ]);

    app.config(['$routeProvider', function ($routeProvider) {
        var rootUrl = 'Scripts/App/';
        $routeProvider
            .when('/', {
                templateUrl: rootUrl + '/catalog/html/manage.html',
                controller: 'manageCtrl'
            })
            .when('/catalogs/manage', {
                templateUrl: rootUrl + '/catalog/html/manage.html',
                controller: 'manageCtrl'
            })
            .when('/catalogs/manage/add', {
                templateUrl: rootUrl + '/catalog/html/manageAddProd.html',
                controller: 'manageAddProdCtrl'
            })
            .when('/catalogs/manage/prod/:id', {
                templateUrl: rootUrl + '/catalog/html/manageProdDetails.html',
                controller: 'manageProdDetailsCtrl'
            })
            .when('/catalogs/categories', {
                templateUrl: rootUrl + '/catalog/html/categories.html',
                controller: 'categoriesCtrl'
            })
            .otherwise({
                redirectTo: '/notfound',
                templateUrl: rootUrl + '/shared/html/notFound.html'
            });
    }]);
    app.config(function ($httpProvider) {
        $httpProvider.interceptors.push('httpInterceptor');
    });
    app.run(['$route', function ($route) {
        //put the $route as dependency so that it will initialize the ng-view inside the ng-include
        //this will kick start the route engine once the ng-view is loaded
    }]);
})();